package de.muahd.saga.ui.vaadin.views.components.menu;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import com.vaadin.ui.MenuBar;
import com.vaadin.ui.MenuBar.Command;
import com.vaadin.ui.MenuBar.MenuItem;
import com.vaadin.ui.VerticalLayout;

@Component
@Scope("prototype")
public class Menu extends VerticalLayout {

	private MenuBar menubar = new MenuBar();

	public Menu() {

		// Save reference to individual items so we can add sub-menu items to
		// them
		final MenuBar.MenuItem file = menubar.addItem("File", null);
		final MenuBar.MenuItem newItem = file.addItem("Customer", null);
		file.addSeparator();

		newItem.addItem("New", menuCommand);



		addComponent(menubar);
	}

	private Command menuCommand = new Command() {
		@Override
		public void menuSelected(MenuItem selectedItem) {
			getWindow().showNotification("Action " + selectedItem.getText());
		}
	};

}
